package com.sneakxy.cloudbase.platform.interceptor;

import java.lang.reflect.Method;

import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;
import org.springframework.core.annotation.AnnotationUtils;

import com.sneakxy.cloudbase.platform.utils.web.signature.RequireSignature;

public class CloudBaseAuthorizationAttributeSourceAdvisor extends AuthorizationAttributeSourceAdvisor {

	/**
	 * 
	 */
	private static final long serialVersionUID = -3984653142685983312L;

	@Override
	@SuppressWarnings("rawtypes")
	public boolean matches(Method method, Class targetClass) {
		if(isSignatureAnnotationPresent(method)) {
			return true;
		}
		return super.matches(method, targetClass);
	}

	protected boolean isSignatureAnnotationPresent(Method method) {
        return AnnotationUtils.findAnnotation(method, RequireSignature.class) != null;
    }
	
}
